{extend name="public:base"/}
{block name="main"}

<form class="layui-form" action="" method="POST" lay-filter="form">
  <div class="layui-form-item">
      <label class="layui-form-label">上级菜单</label>
      <div class="layui-input-inline width-350"  >
         <select name="pid" lay-filter="select" id="catelist">
          <option value="0">一级菜单</option>
           
        </select>  
      </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label"><span class="form-required">*</span>分类名称</label>
    <div class="layui-input-inline  width-350">
      <input type="text" name="catename" lay-verify="required"  placeholder="请输入分类名称" autocomplete="off" class="layui-input" value="">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">seo关键字</label>
    <div class="layui-input-block  width-350">
      <input type="text" name="keyword"  placeholder="请输入分类关键字" autocomplete="off" class="layui-input" value="">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">seo描述</label>
    <div class="layui-input-block  width-350">
      <input type="text" name="description"  placeholder="请输入分类描述" autocomplete="off" class="layui-input" value="">
    </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label"><span class="form-required">*</span>模型</label>
      <div class="layui-input-inline width-350" >
        <select name="modelid" lay-verify="required" lay-filter="modelid" id="catetype" >
         
          <option value="">请选择一个模型</option>
            
        </select>   
      </div>
  </div>
  
  <div class="layui-form-item">
     <label class="layui-form-label">缩略图</label>
     <div class="layui-input-inline  width-350" >
       <input type="text" name="catethumb"  placeholder="图片地址" autocomplete="off" class="layui-input"  value="">
       
     </div>
     <div class="layui-word-aux">
       
        <img src="" class="content-photos" >
        
       <button type="button" class="layui-btn layui-btn-small layui-btn-normal fileupload"  lay-data="{data:{type:'image'},accept:'images'}">
         <i class="layui-icon">&#xe60d;</i>上传图片
       </button>
     </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">跳转链接</label>
    <div class="layui-input-block width-350">
      <input type="text" name="url" requplaceholder="请输入跳转链接" autocomplete="off" class="layui-input" value="">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">备注</label>
    <div class="layui-input-inline">
      <input type="text" name="other" requplaceholder="请输入分类备注名称" autocomplete="off" class="layui-input" value="">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">导航栏</label>
    <div class="layui-input-block">
      <input type="checkbox" name="isnav" lay-skin="switch" lay-text="显示|隐藏" lay-filter="switchTest" value="1" checked>
      <div class="layui-unselect layui-form-switch" lay-skin="_switch">
        <em>OFF</em><i></i>
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
      <input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" lay-filter="switchTest" value="1" checked>
      <div class="layui-unselect layui-form-switch" lay-skin="_switch">
        <em>OFF</em><i></i>
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">排序</label>
    <div class="layui-input-inline width-350">
      <input type="number" name="catepx"  placeholder="请输入数字排序" autocomplete="off" class="layui-input" value="">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

<script type="text/javascript">
	layui.use(['form','upload'], function(){
	  form = layui.form;
    upload=layui.upload;

    var obj = {
        url: '{:Url('common/fileupload',array('width'=>"60",'height'=>"60",'notwater'=>"1"))}' 
        ,inc:function(res){
            $("input[name='catethumb']").val(res.path);
             $(".content-photos").attr("src",res.path);
        }

    };
    admin.fileupload(obj);

    form.on('select(select)', function(data){
      $("input[name='url']").val("");
    });  

    layer.photos({
      photos: '.layui-word-aux'
      ,anim: 5 
    }); 

    admin.submit();
    

    obj = {

      inc:function(data){

        if(data.modellist.length > 0){

          var modellist = '<option value="">请选择一个模型</option>';

          for(i in data.modellist){

            modellist += '<option value="'+data.modellist[i].modelid+'">'+data.modellist[i].name+'</option>';
             
          }

          $("#catetype").html(modellist);
          
        }

        if(data.catelist.length > 0){

          var catelist = '<option value="0">一级菜单</option>';

          for(i in data.catelist){

            catelist += '<option value="'+data.catelist[i].cateid+'">'+data.catelist[i].catename+'</option>';
             
          }

          $("#catelist").html(catelist);

        }


      }

    };
    
    admin.edit(obj);

    
	  
	});
</script>

{/block}